package org.kingtop.mybatis.session;

import org.apache.ibatis.binding.MapperRegistry;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.kingtop.mybatis.binding.MybatisMapperRegistry;

/**
 * 主要替换MybatisMapperRegistry
 * 
 * @author Caratacus hubin
 * @author 陈金波
 * @date 2018年1月8日 下午10:38:17
 * @Copyright: 2018 chen jinbo. All rights reserved.
 */
public class MybatisConfiguration extends Configuration {

	/**
	 * Mapper 注册
	 */
	public final MybatisMapperRegistry mybatisMapperRegistry = new MybatisMapperRegistry(this);

	/**
	 * 初始化调用
	 */
	public MybatisConfiguration() {
		super();
	}

	@Override
	public MapperRegistry getMapperRegistry() {
		return mybatisMapperRegistry;
	}

	@Override
	public <T> void addMapper(Class<T> type) {
		mybatisMapperRegistry.addMapper(type);
	}

	@Override
	public void addMappers(String packageName, Class<?> superType) {
		mybatisMapperRegistry.addMappers(packageName, superType);
	}

	@Override
	public void addMappers(String packageName) {
		mybatisMapperRegistry.addMappers(packageName);
	}

	@Override
	public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
		return mybatisMapperRegistry.getMapper(type, sqlSession);
	}

	@Override
	public boolean hasMapper(Class<?> type) {
		return mybatisMapperRegistry.hasMapper(type);
	}

}
